/*
 * This file is part of JContextFree.
 *
 * JContextFree is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JContextFree is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JContextFree.  If not, see <http://www.gnu.org/licenses/>.
 */

package it.enricod.jcontextfree.gui.impl;

import it.enricod.jcontextfree.gui.IProgramsTabbedPane;
import it.enricod.jcontextfree.gui.IMainFrame;
import it.enricod.jcontextfree.gui.IProgramCodePanel;

import java.awt.BorderLayout;
import java.awt.Container;

import javax.swing.JFrame;

import com.google.inject.Inject;
import it.enricod.jcontextfree.engine.samples.IProgramsCatalog;

public class MainFrame implements IMainFrame {

	private JFrame _frame = new JFrame();
	private IProgramsTabbedPane programsTabbedPane;
	private ToolBar toolBar;
	private ProgramCodePanel programPanel;
	private IProgramsCatalog programsCatalog;

	@Inject
	public MainFrame(IProgramsTabbedPane tabbedPane, ProgramCodePanel programPanel, IProgramsCatalog programsCatalog) {
		this.programsTabbedPane = tabbedPane;
		this.programPanel = programPanel;
		this.programsCatalog = programsCatalog;

		_frame = new JFrame("JContextFree");
		init();
	}

	private void init() {
		Container mainPanel = _frame.getContentPane();
		_frame.setSize(800, 600);
		_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		mainPanel.setLayout(new BorderLayout());
		toolBar = new ToolBar(this);

		mainPanel.add(toolBar.getToolBar(), BorderLayout.PAGE_START);
//		mainPanel.add(programPanel.getPanel(), BorderLayout.WEST);
		mainPanel.add(programsTabbedPane.getTabbedPane(), BorderLayout.CENTER);
	}

	public void setVisible(boolean flag) {
		_frame.setVisible(flag);
	}

	public IProgramsTabbedPane getProgramsTabbedPane() {
		return programsTabbedPane;
	}

	public IProgramCodePanel getProgramPanel() {
		return programPanel;
	}

	public IProgramsCatalog getProgramsCatalog() {
		return this.programsCatalog;
	}
}
